package com.corewillsoft.fireflies.storage.objects;

import java.util.List;

import android.content.ContentValues;
import android.text.TextUtils;

import com.corewillsoft.fireflies.storage.entries.SavedGameLevelEntries;
import com.corewillsoft.fireflies.util.TypesConverter;

public class SavedGameLevel extends BaseGameLevel {

	public SavedGameLevel(BaseGameLevel gameLevel) {
		super(gameLevel);
	}

	public SavedGameLevel() {
	}

	@Override
	public List<Float> getFireflyEnergy() {
		return fireflyEnergy;
	}

	@Override
	public List<Boolean> getFireflyAlive() {
		return fireflyAlive;
	}

	@Override
	public List<Boolean> getFireflySaved() {
		return fireflySaved;
	}

	@Override
	public ContentValues toContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(SavedGameLevelEntries.LEVEL, getLevel());
		
		cv.put(SavedGameLevelEntries.FIREFLY_IDS, TextUtils.join(",", fireflyIds));
		cv.put(SavedGameLevelEntries.FIREFLY_X, TextUtils.join(",", fireflyX));
		cv.put(SavedGameLevelEntries.FIREFLY_Y, TextUtils.join(",", fireflyY));
		cv.put(SavedGameLevelEntries.FIREFLY_ENERGY, TextUtils.join(",", fireflyEnergy));
		cv.put(SavedGameLevelEntries.FIREFLY_ALIVE, TextUtils.join(",", fireflyAlive));
		cv.put(SavedGameLevelEntries.FIREFLY_SAVED, TextUtils.join(",", fireflySaved));

		cv.put(SavedGameLevelEntries.PORTAL_IDS, TextUtils.join(",", portalIds));
		cv.put(SavedGameLevelEntries.PORTAL_X, TextUtils.join(",", portalX));
		cv.put(SavedGameLevelEntries.PORTAL_Y, TextUtils.join(",", portalY));

		cv.put(SavedGameLevelEntries.OBSTACLE_IDS, TextUtils.join(",", obstacleIds));
		cv.put(SavedGameLevelEntries.OBSTACLE_X, TextUtils.join(",", obstacleX));
		cv.put(SavedGameLevelEntries.OBSTACLE_Y, TextUtils.join(",", obstacleY));

		cv.put(SavedGameLevelEntries.OBSTACLES_PARAMS, getObstaclesParametersString());
		
		cv.put(SavedGameLevelEntries.SAVED_TIME, System.currentTimeMillis());
		cv.put(SavedGameLevelEntries.COMPLETED, TypesConverter.bool2int(false));
		return cv;
	}
}
